<template>
	<div class="contanier">
		<div class="swiper-container swiper-container-horizontal swiper-no-swiping carouselBox carouselLeft" id="swiper-container">
			<div class="swiper-wrapper imgBox">
				<a class="swiper-slide swiper-slide-prev block_a carousel" :href="Path + item?.url" target="_blank" v-for="(item, index) in records" :key="index">
					<div class="carouselLeft">
						<img :src="getImgPath((item.extend?.singleImgUploadFuQ2 ? item.extend.singleImgUploadFuQ2[0]?.url :'') || item.headImag)" 
						alt="" class="img1" />
					</div>
				</a>
			</div>
		</div>
		<div class="carouselRight">
			<p class="p1">{{ activeTitle }}</p>
			<p class="p2">{{ activeSumay }}</p>
			<div class="direction">
				<div class="swiperButton swiperButton_left"><span class="iconfont icon-a-Leftarrow"></span></div>
				<div class="swiperButton swiperButton_right"><span class="iconfont icon-a-Rightarrow"></span></div>
			</div>
			<div class="swiper-pagination1 instBox"></div>
		</div>
	</div>
</template>

<script>
export default {
	data() {
		return {
			records: [
				{
					headImag: '',
					summary: '',
					title: '',
					content: ''
				}
			],
			Path: getRootPath(),
			activeTitle: '',
			activeSumay: ''
		};
	},
	mounted() {
		this.headline();
	},

	methods: {
		inintSlide() {
			let _this = this;
			let swiper = new Swiper('.swiper-container', {
				pagination: {
				        el: ".swiper-pagination1",
				        clickable: true,
				      },
				paginationClickable: true,
				navigation: {
				    nextEl: ".swiperButton_right",
				    prevEl: ".swiperButton_left",
				},
				parallax: true,
				speed: 1500,
				loop: true,
				// autoplay: 5000,
				autoplay: {
				        delay: 5000,
				      },
				on:{
					transitionStart:function(swiper){
						let e = this;
						if (e.activeIndex > _this.records?.length) {
							_this.activeTitle = _this.records[0].title;
							_this.activeSumay = _this.records[0].summary;
						} else if (e.activeIndex == 0) {
							_this.activeTitle = _this.records[_this.records.length - 1]?.title;
							_this.activeSumay = _this.records[_this.records.length - 1]?.summary;
						} else {
							_this.activeTitle = _this.records[e.activeIndex - 1]?.title;
							_this.activeSumay = _this.records[e.activeIndex - 1]?.summary;
						}
					}
				}
			});
		
			$('.swiper-container').mouseover(function() {

				swiper.autoplay.stop();
			});
			$('.swiper-container').mouseout(function() {
				swiper.autoplay.start();
			});
			$('.carouselRight').mouseover(function() {
				// 停止自动滚动
				swiper.autoplay.stop();
				// 停止自动滚动
			});
			$('.swiper-container').mouseout(function() {
				swiper.autoplay.start();
			});
		},
		headline() {
			let param = {
				orderBy: 1,
				typeIdStr: '1001',
				pageSize: 3,
				pageNum: 1
			};
			contentApi.fetchContentOfChannel(param, res => {
				if (res.code == '00000 00000') {
					this.records = res.data.records;
					this.$nextTick(() => {
						this.inintSlide();
					});
				} else {
				}
			});
		},
		getImgPath(url) {
			return imgPath(url);
		}
	}
};
</script>

<style>


.contanier .carouselLeft {
	flex: 1;
	height: fit-content;
	border-radius: 4px 0 0px 4px;
}
.contanier .carouselLeft .img1 {
	width: 100%;
	height:auto;
}
.contanier .carouselRight {
	position: relative;
	color: #fff;
	box-sizing: border-box;
	background: url('https://demo.jeecms.com/u/cms/www/2023/08/01/1686271175187095553.png') center no-repeat;
	background-size: cover;
	z-index:1;
}
.contanier .carouselRight .p1 {
	font-family: PingFang SC-Medium, PingFang SC;
	font-weight: 500;
	color: #ffffff;
	line-height: 32px;
	margin-bottom: 24px;
	text-overflow: -o-ellipsis-lastline;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
}
.contanier .carouselRight .p2 {
	font-family: PingFang SC-Regular, PingFang SC;
	font-weight: 400;
	color: #ffffff;
	line-height: 24px;
	text-overflow: -o-ellipsis-lastline;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 5;
	line-clamp: 5;
	-webkit-box-orient: vertical;
}
.contanier .carouselRight .direction {
	position: absolute;
	width: 50px;
	z-index: 10;
	display: flex;
	justify-content: space-between;
}
.contanier .carouselRight .direction .swiperButton {
	width: 20px;
	height: 20px;
	background: #fff;
	border-radius: 100%;
	line-height: 20px;
	text-align: center;
}
.contanier .carouselRight .direction .swiperButton .iconfont {
	color: #ff3333;
	font-size: 16px;
	font-weight: 400;
	opacity: 1;
}
.contanier .carouselRight .swiper-pagination1 {
	position: absolute;

	display: flex;
	justify-content: flex-end;
}
.contanier .carouselRight .swiper-pagination-bullet {
	background-color: #fff;
	opacity: 0.5;
	margin-right: 8px;
}
.contanier .carouselRight .swiper-pagination-bullet-active {
	opacity: 1;
}
/* .contanier .swiper-slide {
	width: 100.051111% !important;
} */
@media (min-width: 1400px) {
  .contanier {
  	width: 72.955%;
		max-width: 1400px;
  	height: fit-content;
  	margin-top: 48px;
  	position: relative;
  	display: flex;
  }
	.contanier .carouselRight {
		width: 336px;
		padding: 56px 40px 0;
	}
	.contanier .carouselRight .p1 {
		font-size: 24px;
		line-height: 32px;
		margin-bottom: 24px;
	}
	.contanier .carouselRight .p2 {
		font-size: 16px;
		line-height: 24px;
	}
	.contanier .carouselRight .direction {
	
		width: 50px;
		left: 42px;
		bottom: 32px;
		z-index: 10;
		height: 20px;
	}
	.contanier .carouselRight .swiper-pagination1 {
		right: 32px;
		bottom: 40px;
	}
}
@media (max-width: 1366px) {
  .contanier {
  	width: 1239.78px;
  	height: fit-content;
  	margin-top: 48px;
  	position: relative;
  	display: flex;
  }
	.contanier .carouselRight {
		width: 297.38px;
		padding: 50px 35px 0;
	}
	.contanier .carouselRight .p1 {
		font-size: 20px;
		line-height: 32px;
		margin-bottom: 24px;
	}
	.contanier .carouselRight .p2 {
		font-size: 14px;
		line-height: 24px;
	}
	.contanier .carouselRight .direction {
	
		width: 50px;
		left: 36px;
		bottom: 30px;
		z-index: 10;
		height: 20px;
	}
	.contanier .carouselRight .swiper-pagination1 {
		right: 38px;
		bottom: 33px;
	}
}
</style>
